using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class pages_Place : PagedPage
{
    public override string RequestString
    {
        get { return "Place.aspx?cate="+Request["cate"]+"&page="; }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        p = Request["page"];
        totals = 0;
        currentPage = GetPageNumber(p);
        try
        {
            int cate_id = int.Parse(Request["cate"]);            
            PlaceDAO daoPlace = new PlaceDAO();
            PlaceCategoryDAO daoPlaceCate = new PlaceCategoryDAO();
            PlaceCategory cate = daoPlaceCate.GetPlaceCategory(cate_id);
            lblTitle.Text = cate.Name;
            pageSize = 10;
            if (cate.Name.ToLower()!="hotel")
            { //restaurant or report
                rptPlace.Visible = true;
                rptPlace.DataSource = daoPlace.GetPlacesByCategory(currentPage, pageSize, ref totals, cate_id, "%", ServiceObject.Published);
                rptPlace.DataBind();
            }
            else
            {
                rptHotel.Visible = true;
                rptHotel.DataSource = daoPlace.GetPlacesByCategory(currentPage, pageSize, ref totals, cate_id, "%", ServiceObject.Published);
                rptHotel.DataBind();
            }
            lblPaging.Text = GetPageGrid(totals, pageSize, currentPage);
        }
        catch (Exception ex)
        {
            throw ex;
        }
        
    }
    /// <summary>
    /// Get visible value for 'quality' field of hotel
    /// </summary>
    /// <param name="rank"></param>
    /// <returns></returns>
    public bool GetQualityState(object rank)
    {
        int q = int.Parse(rank.ToString());
        if(q>0 && q<6)return true;
        return false;
    }
   
}
